package ch13;

import java.util.ArrayList;

// BalanceInquiry.java
// Represents a balance inquiry ATM transaction

// BalanceInquiry inherits from the superclass Option
public class BalanceInquiry extends Option {

	// irrelevant stringarray for menu-visualization
	private ArrayList<String> stringArray = new ArrayList<String>();

	Keypad keypad;

	// BalanceInquiry constructor
	public BalanceInquiry(int userAccountNumber, Screen atmScreen,
			BankDatabase atmBankDatabase) {
		super(userAccountNumber, atmScreen, atmBankDatabase);
		keypad = new Keypad();
	} // end BalanceInquiry constructor

	// performs the Option
	public void execute() {
		// get references to bank database and screen
		BankDatabase bankDatabase = getBankDatabase();

		ArrayList<Account> accounts = bankDatabase.getCustomer(getUserID())
				.getAccounts(); // save customer accounts to arraylist accounts

		stringArray.clear(); // clear the screen box

		// print out customers account type, total and available
		// balance
		for (int i = 0; i < accounts.size(); i++) {
			stringArray.add("BalanceInquiry Menu:");
			stringArray.add("Account Type:  " + accounts.get(i).getType());
			stringArray.add("TotalBalance: "
					+ accounts.get(i).getTotalBalance());
			stringArray.add("AvailableBalance: "
					+ accounts.get(i).getAvailableBalance());
			stringArray.add("");
		} // end for loop
      
		screen.setKasse(stringArray, 10); // set the size of the screen box
	} // end method execute
} // end class BalanceInquiry